package ccgl.com.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import ccgl.com.dao.common.BaseDao;
import ccgl.com.factory.ConnectionFactory;
import ccgl.com.model.MDdxx;

/**
 * 商品管理Dao
 * 
 * @author Administrator
 * 
 */
public class DdxxDao extends BaseDao<MDdxx> {

	/**
	 * 添加订单详细信息
	 * @param dd
	 * @return
	 * @throws SQLException
	 */
	public boolean addDdxx(MDdxx dd) throws SQLException {
		return false;
//		String sql = "insert into ddb(id,ddh,khxm,khdh,xsr,ddzj,userid,ddsj,gxsj) values(?,?,?,?,?,?,?,?,?)";
//		Connection con = ConnectionFactory.getConnection();
//		try {
//			if (super.update(sql, con, dd.getPropertiesArray()) > 0) {
//				return true;
//			}
//		} finally {
//			con.close();
//		}
//		return false;
	}

	/**
	 * 更新订单详细信息
	 * @param dd
	 * @return
	 * @throws SQLException
	 */
	public boolean updateDdxx(MDdxx dd) throws SQLException {
//		String sql = "update ddb set  ddh=?,khxm=?,khdh=?,xsr=?,ddzj=?,ddsj=?,gxsj=? where id='" + dd.getId() + "'";
//		Connection con = ConnectionFactory.getConnection();
//		try {
//			if (super.update(sql, con, dd.getPropertiesUpdateArray()) > 0) {
//				return true;
//			}
//		} finally {
//			con.close();
//		}
		return false;
	}

	public boolean exists(String ddh, String userid) throws SQLException {
//		String sql = "select count(*) from ddb where ddh='" + ddh + "' and userid='" + userid + "'";
//		Connection con = ConnectionFactory.getConnection();
//		try {
//			if (super.getCount(sql, con) > 0) {
//				return true;
//			}
//		} finally {
//			con.close();
//		}
		return false;
	}
	
	public Map getDdxxList(int star, int end, String ddid) throws SQLException {
		String sql = "SELECT * FROM ddxx where ddid='" + ddid + "' LIMIT " + star + "," + end;
		String countSql = "select count(*) from ddxx where ddid='" + ddid + "'";
		return getDdxxList(sql, countSql);
	}


	public Map getDdxxList(String sql, String countSql) throws SQLException {
		Map map = new HashMap();
		Connection con = ConnectionFactory.getConnection();
		try {
			map.put("Rows", super.queryForList(sql, con));
			map.put("Total", super.getCount(countSql, con));
		} finally {
			con.close();
		}
		return map;
	}

	public boolean deleteDdxxs(String idStr) throws SQLException {
//		String sql = "delete from ddb  where id in (" + idStr + ")";
//		Connection con = ConnectionFactory.getConnection();
//		try {
//			if(super.update(sql, con) > 0) {
//				return true;
//			}
//		} finally {
//			con.close();
//		}
		return false;
	}
}
